package com.weisy.signin.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;

/**
 * @author weisy
 * @function
 * @date 2019/3/23 15:17
 */
public class TimeUtils {
    private static final SimpleDateFormat FORMAT_YMD = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINESE);

    public static String getCurrent() {
        return FORMAT_YMD.format(Calendar.getInstance().getTime());
    }

    /**
     * 时间比较
     * @param start start
     * @return 差值
     */
    public static int compareTime(String start){
        try {
            long current = System.currentTimeMillis();
            long last = FORMAT_YMD.parse(start).getTime();
            return (int) ((current-last)/1000);
        } catch (ParseException e) {
            e.printStackTrace();
            return 100;
        }
    }
}
